<?php

class reports extends CI_Controller
{

    public function __construct()
    {
        parent::__construct();
        $this->load->model('devicemodel');
    }

    public function devices()
    {
        $this->load->helper('form');
        $this->load->library('form_validation');

        $this->form_validation->set_rules('purchase_date', 'purchase_date', 'required');
        $this->form_validation->set_rules('region', 'region', 'required');
        $this->form_validation->set_rules('location', 'location', 'required');

        if ($this->form_validation->run() === FALSE) {
            $this->load->view('reports/view');

        } else {
            $data['stats'] = $this->devicemodel->getreport();
            $this->load->view('reports/viewdevicereports', $data);
        }
    }
}

?>